<?php
session_start();
require_once 'header.php';
function __autoload($className)
	{
    	require_once('class/' . $className . '.class.php');
	}
	
		if(isset($_POST["submit"]))
		{
			$user=$_POST["user"];
			$pass=$_POST["pass"];
			$check=user::checklogin($user, $pass);
			if($check=='0')
			{
				$_SESSION["erro"]="INCORRECT USER AND PASSWORD";
              	redirect::location("index.php");
			}
			else 
			{
                 $userid=$check['userid'];
                 $_SESSION["userid"]=$userid;
                 $permission=$check['permission'];      
                if($permission==1)
                {
                	session::setsessiongroup("manager");
                	redirect::location("admincp.php");
                }
                else if($permission==3)
                {
                	
                	redirect::location("verify.php");
                	
                }
                else if($permission==2)
                {
                	session::setsessiongroup("seller");
                	redirect::location("seller.php");
                }
                else
                {
                	$_SESSION["erro"]="Incorrect username and password";
                	redirect::location("login.php");
                	
                }
                             
				
			}
			
			
		}
		else if(!empty($_POST["signup"]))
		{
			redirect::location("signup.php");
		}
		else 
		{
			require_once 'html/signin.php';
		}
		
	

?>